package com.hdaccp.ch08
import org.apache.spark.sql.SparkSession
import org.apache.spark.sql.functions._
import scala.collection.mutable.ListBuffer
object Demo7 {
  def main(args: Array[String]): Unit = {
    //1.SparkSession
    val spark = SparkSession.builder()
      .master("local[2]")
      .appName("ch08Demo1App")
      .getOrCreate()

   /* val rdd = spark.sparkContext.textFile("F:\\accp教学\\sparkresources\\music1.txt")

    //rdd => DataFrame
   val df = rdd.map(x=>x.split("\t")).map(y=>Music(y(0),y(1),y(2),y(3),y(4),y(5))).toDF()*/


    val df = spark.read.format("parquet").load("F:\\accp教学\\sparkresources\\clean12")

    df.select("types","zd").groupBy("types","zd").agg(count("zd").as("times")).orderBy(count("zd").desc).show()

   // df.show()
    spark.stop()
  }
}
